
<div class="form">
	<p></p>
	<form id="ndk-health-form" method="post" action="<?php echo Yii::app()->createUrl('soa/showAging'); ?>" target="_blank">
		<div class="row">
			<div class="col-md-4">
				<div class="widget box">

					<div class="widget-header">
						<h4><i class="icon-reorder"></i> Report Aging </h4>
					</div>


					<div class="widget-content">
						<strong><h4>Periode</h4></strong>

						<div class="control-group">
						<label class="control-label">Tanggal</label>
						<div class="controls">
						<select id="tanggal" name="tanggal">
						<option value="01">1</option>
						<option value="02">2</option>
						<option value="03">3</option>
						<option value="04">4</option>
						<option value="05">5</option>
						<option value="06">6</option>
						<option value="07">7</option>
						<option value="08">8</option>
						<option value="09">9</option>
						<option value="10">10</option>
						<option value="11">11</option>
						<option value="12">12</option>
						<option value="13">13</option>
						<option value="14">14</option>
						<option value="15">15</option>
						<option value="16">16</option>
						<option value="17">17</option>
						<option value="18">18</option>
						<option value="19">19</option>
						<option value="20">20</option>
						<option value="21">21</option>
						<option value="22">22</option>
						<option value="23">23</option>
						<option value="24">24</option>
						<option value="25">25</option>
						<option value="26">26</option>
						<option value="27">27</option>
						<option value="28">28</option>
						<option value="29">29</option>
						<option value="30">30</option>
						<option value="31">31</option>
						</select>
						</div>
						</div>


						<div class="control-group">
						<label class="control-label">Bulan</label>
						<div class="controls">
						<select id="bulan" name="bulan" class="form-control">
						<option value="01">Januari</option>
						<option value="02">Februari</option>
						<option value="03">Maret</option>
						<option value="04">April</option>
						<option value="05">Mei</option>
						<option value="06">Juni</option>
						<option value="07">Juli</option>
						<option value="08">Agustus</option>
						<option value="09">September</option>
						<option value="10">Oktober</option>
						<option value="11">November</option>
						<option value="12">Desember</option>
						</select>
						</div>
						</div>


						<div class="control-group">
						<label class="control-label">Tahun</label>
						<div class="controls">
						<input id="tahun" class="form-control" type="text" name="tahun" size="100">
						</div>
						</div>

					</div>

				</div>
			</div>
		</div>

		<div class="row">
			<div class="col-md-4">
				<div class="form-actions">
					<button class="btn btn-primary btn-large" id="btn_prev" type="button">Preview</button>
					<button class="btn btn-primary btn-large" name="yt0" type="submit">Cetak</button>
				</div>
			</div>
		</div>
	</form>

</div>



<div class="form">
RUPIAH <br/>
<table class="table table-hover table-striped table-bordered table-highlight-head" id="tbl_aging">
	<thead>
		<tr>
			<th style="text-align:center">Client No.</th>
			<th style="text-align:center">Client Name</th>
			<th style="text-align:center">Total</th>
			<th style="text-align:center">Undue</th>
			<th style="text-align:center">30 Days</th>
			<th style="text-align:center">60 Days</th>
			<th style="text-align:center">90 Days</th>
			<th style="text-align:center">>90 Days</th>
		</tr>
	</thead>
	<tbody id="body_rupiah">
	
	</tbody>
</table>	
</div>


<div class="form">
Dolar <br/>
<table class="table table-hover table-striped table-bordered table-highlight-head" id="tbl_aging_2">
	<thead>
		<tr>
			<th style="text-align:center">Client No.</th>
			<th style="text-align:center">Client Name</th>
			<th style="text-align:center">Total</th>
			<th style="text-align:center">Undue</th>
			<th style="text-align:center">30 Days</th>
			<th style="text-align:center">60 Days</th>
			<th style="text-align:center">90 Days</th>
			<th style="text-align:center">>90 Days</th>
		</tr>
	</thead>
	<tbody id="body_dolar">
	
	</tbody>
	</table>
</div>

<div class="form">
Euro<br/>
<table class="table table-hover table-striped table-bordered table-highlight-head" id="tbl_aging_3">
	<thead>
		<tr>
			<th style="text-align:center">Client No.</th>
			<th style="text-align:center">Client Name</th>
			<th style="text-align:center">Total</th>
			<th style="text-align:center">Undue</th>
			<th style="text-align:center">30 Days</th>
			<th style="text-align:center">60 Days</th>
			<th style="text-align:center">90 Days</th>
			<th style="text-align:center">>90 Days</th>
		</tr>
	</thead>
	<tbody id="body_euro">
	
	</tbody>
	</table>
</div>



<script type="text/javascript">
function formatCurrency(total) {
    var neg = false;
    if(total < 0) {
        neg = true;
        total = Math.abs(total);
    }
    return (neg ? "" : '') + parseFloat(total, 10).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, "$1,").toString();
}

$("#btn_prev").click(function(e){
	var isi_cicilan = "";
	$.ajax({
			type:"POST",
            url:"<?php echo Yii::app()->createUrl('/Soa/showAging'); ?>",
			data:{},
			dataType:"json",
            success:function(data){
				$("#body_rupiah").html("");
				$("#body_dolar").html("");
				$("#body_euro").html("");
				var total_debet_rp = parseInt(0);
				var total_kredit_rp = parseInt(0);
				
				var total_debet_dolar = parseInt(0);
				var total_kredit_dolar = parseInt(0);
				
				var total_debet_euro = parseInt(0);
				var total_kredit_euro = parseInt(0);
				
				for(var i=0;i<data.length;i++){
					if(data[i].jns_mata_uang == 'Rp'){
						$("#body_rupiah").append("<tr>" +
						"<td>"+data[i].client_number+"</td>"+
						"<td>"+data[i].name+"</td>"+
						"<td>"+data[i].jns_mata_uang+" "+formatCurrency(data[i].gross_premi)+"</td>"+
						"<td align='center'>"+data[i].telat1+"</td>"+
						"<td align='center'>"+data[i].telat2+"</td>"+
						"<td align='center'>"+data[i].telat3+"</td>"+
						"<td align='center'>"+data[i].telat4+"</td>"+
						"<td align='center'>"+data[i].telat5+"</td>"+
						"</tr>");
					}else if(data[i].jns_mata_uang == '$'){
						$("#body_dolar").append("<tr>" +
						"<td>"+data[i].client_number+"</td>"+
						"<td>"+data[i].name+"</td>"+
						"<td>"+data[i].jns_mata_uang+" "+formatCurrency(data[i].gross_premi)+"</td>"+
						"<td align='center'>"+data[i].telat1+"</td>"+
						"<td align='center'>"+data[i].telat2+"</td>"+
						"<td align='center'>"+data[i].telat3+"</td>"+
						"<td align='center'>"+data[i].telat4+"</td>"+
						"<td align='center'>"+data[i].telat5+"</td>"+
						"</tr>");
					}else if(data[i].jns_mata_uang == 'E'){
						$("#body_euro").append("<tr>" +
						"<td>"+data[i].client_number+"</td>"+
						"<td>"+data[i].name+"</td>"+
						"<td>"+data[i].jns_mata_uang+" "+formatCurrency(data[i].gross_premi)+"</td>"+
						"<td align='center'>"+data[i].telat1+"</td>"+
						"<td align='center'>"+data[i].telat2+"</td>"+
						"<td align='center'>"+data[i].telat3+"</td>"+
						"<td align='center'>"+data[i].telat4+"</td>"+
						"<td align='center'>"+data[i].telat5+"</td>"+
						"</tr>");
					}	
				}
				
				
			}
	});
});//end click
</script>